const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack'); // 用于访问内置插件
const path = require('path');
module.exports = {

  output: {
    filename: '[name][hash].js',
    hashDigestLength: 7,
    path: path.resolve(__dirname, './dist'),
    clean: true,
  },
  devServer: {
    static: {
      directory: path.join(__dirname, 'src'),

    },
    compress: true,
    port: 9000,
  },
  module: {
    rules: [{ test: /\.txt$/, use: 'raw-loader' }],
    rules: [
      {
        test: /\.(jpg|glb|jpeg|png|gif|ico)$/,
        use: [
          {
            loader: 'file-loader',
            options: {
              name: '[name].[ext]',
              outputPath: 'images/'
            }
          }
        ]
      },
    ]
  },
  plugins: [new HtmlWebpackPlugin({ template: './src/index.html' })],
};